package renda.action.admin;

import renda.common.Constants;
import renda.common.SessionUtil;
import renda.dao.serivce.AdminService;
import renda.pojo.Admins;

public class LoginAction {

	private Admins admin = new Admins();

	private AdminService adminService;

	public String execute() {
		Admins admin1 = adminService.login(admin);
		if (admin1.getAid() != null) {
			SessionUtil.setAttr("curradmin", admin1);
			SessionUtil.setAttr(Constants.USER_TYPE, Constants.USER_TYPE_ADMIN);
			return "success";
		}
		SessionUtil.setAttr("userloginerror", "用户名或密码错误");
		return "error";
	}

	public void setAdmins(Admins admin) {
		this.admin = admin;
	}

	public Admins getAdmin() {
		return admin;
	}

	public void setAdminService(AdminService adminService) {
		this.adminService = adminService;
	}
}
